import { attackRoles } from "utils/constants/bodyconstant";
import { FormationPattern } from "../FormationPattern";
import { Matrix3, SlotAssignment, Static } from "../types";

export class Team4Pattern<T extends Charactor> extends FormationPattern<T>
{
    public getRotateIndex(): false | number[] 
    {
        return false
    }
    // 默认朝向 +X ------>
    private _slotLocation:IFVector2[]=[{x:0,y:0},{x:1,y:0},{x:0,y:1},{x:1,y:1}];
    private offset:IFVector2={x:0.5,y:0.5};// 用来计算旋转轴
    private offsetStatic = new Static( new Matrix3().makeTranslate({x:0.5,y:0.5}))
    public   getDriftOffset(slotAssignments:SlotAssignment<T>[]):Static
    {
        return this.offsetStatic;
    }
    public   getOffset():IFVector2
    {
        return this.offset
    }
    public getDirection(): IFVector2 {
        return {x:0,y:-1}
    }
    // 获取槽 在队形中的相对位置
    public   getSlotLocation(slotNumber:number):IFVector2
    {
        return this._slotLocation[slotNumber];
    }
    public   getSlotLocations( ):Readonly<IFVector2>[]
    {
        return this._slotLocation
    }
    public getSlotCount(): number {
        return this._slotLocation.length;
    }

    // 如果该图案能支持给定的数量的槽位，则返回true
    public   supportSlots(slotCount:number):boolean
    {
        return slotCount<=this._slotLocation.length;
    }
    public getSlotCost(slot:SlotAssignment<T>):number{

        if(slot.slotNumber<  this._slotLocation.length/2)
        {
            // 前面进攻
            if(attackRoles.has( slot.charactor.ActiveRole() ) )
            {
                return 100;
            }
        }
        else
        {
            // 后面治疗
            if(slot.charactor.ActiveRole() == "idaHeal"  )
            {
                return 100;
            }
        }
        return 0
    }
}
